#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<string.h>
void reverse(char* left, char* right)
{
    while (left < right)
    {
        char tmp = *left;
        *left = *right;
        *right = tmp;
        left++;
        right--;
    }
}
int main()
{
    char str[10000];
    gets(str);
    int len = strlen(str);
    reverse(str, str + len - 1);
    for (int i = 0; i < len; i++)
    {
        if (str[i] <= 'z' && str[i] >= 'a' || str[i] <= 'Z' && str[i] >= 'A')
        {
            continue;
        }
        str[i] = ' ';
    }
    char* s = str;
    char* e = str;
    while (*e != '\0')
    {
        while (*e != ' ' && *e != '\0')
        {
            e++;
        }
        reverse(s, e - 1);
        if (*e == ' ')
        {
            s = e + 1;
        }
        else
        {
            s = e;
        }
        e = s;
    }
    printf("%s", str);
    return 0;
}